package action

import java.util.concurrent.TimeUnit

import akka.actor.{ActorRef, ActorSystem, Props}

import scala.compat.java8.FutureConverters._
import akka.pattern.ask
import akka.util.Timeout

import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future, duration}

/**
 * @Description: TODO
 * @Author: DJJ
 * @Date: 2019/12/3 10:13
 */
object TestActor extends App {

  val system = ActorSystem("AkkademyDb")
  // val actorRef: ActorRef = system.actorOf(Props[AkkademyDb], "db")
  val actorRef: ActorRef = system.actorOf(Props(classOf[AkkademyDb]), "db")
  actorRef ! SetRequest("one", 123)
  implicit val timeOut = Timeout(5, duration.SECONDS)
  val future: Future[Any] = actorRef ? "ping"
  val str: String = Await.result(future.mapTo[String], (1, TimeUnit.SECONDS))
  println(str)
}
